#ifndef D3DOBJ_H
#define D3DOBJ_H

//	The first two libraries contain all the Direct3D functionality for setting up and 
//	drawing 3D graphics in DirectX. 

//	The third library contains tools to interface with the hardware on the computer
//	to obtain information about the refresh rate of the monitor, the video 
//	card being used, and so forth.

#pragma comment(lib, "d3d10.lib")
#pragma comment(lib, "d3dx10.lib")
#pragma comment(lib, "dxgi.lib")

#include <d3d10.h>
#include <d3dx10.h>

class D3DObj
{
public:
	D3DObj();	
	D3DObj(const D3DObj&);
	~D3DObj();

	bool Initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen, 
	float screenDepth, float screenNear);

	void Shutdown();
	
	void BeginScene(float red, float green, float blue, float alpha);
	void EndScene();

	ID3D10Device* GetDevice();

	void SetScreenWidth(int width);
	void SetScreenHeight(int height);

	void GetVideoCardInfo(char* cardName, int& memory);

	bool OnResize();

private:
	bool CalculateRefreshRate(int& Numerator, int& Denominator);
	bool CreateSwapChain(int Numerator, int Denominator, HWND hwnd, bool fullscreen);
	bool CreateDepthBuffer();
	bool CreateStencilBuffer();
	bool CreateRasterState();

private:
	bool m_vsync_enabled;
	int m_videoCardMemory;
	char m_videoCardDescription[128];

	ID3D10Device* m_Device;
	IDXGISwapChain* m_SwapChain;

	ID3D10Texture2D* m_DepthStencilBuffer;
	ID3D10RenderTargetView* m_RenderTargetView;
	ID3D10DepthStencilView* m_DepthStencilView;

	ID3D10DepthStencilState* m_DepthStencilState;
	ID3D10RasterizerState* m_RasterState;

	int m_ScreenWidth;
	int m_ScreenHeight;
};

#endif
